$(function(argument) {
	var uid = window.localStorage.getItem("user_id");
	// console.log(uid);
	var userName = window.localStorage.getItem("user");
	// console.log(userName);
	if (uid == null) {
		window.sessionStorage.setItem("loginFromMyself", 1)
		window.location.href = "login.html";
	} else {

		$(".login span").html(userName);
		$(".login").click(function(e) {
				e.preventDefault();
			})
			// 我的地址页、
		$(".myAddress").click(function(e) {
				e.preventDefault();
				window.location.href = "myAddress.html";
			})
			// 茶券
		$(".myCoupon").click(function(e) {
				e.preventDefault();
				window.location.href = "myCoupon.html";
			})
			// 设置
		$(".set").click(function(e) {
				e.preventDefault();
				window.location.href = "set.html";
			})
			// 我的订单
		$(".myOrderList").click(function(e) {
				e.preventDefault();
				window.location.href = "order_list.html";
			})
			// 商户入驻
		$(".bussinessEnter").click(function(e) {
				e.preventDefault();
				// window.location.href = "bussinessEnter.html";
				$.ajax({
						url: 'http://www.teaweilai.com/app/Admin/AppIcon/Icon',
						type: 'POST',
						dataType: 'json',
						data: {
							uid: uid
						},
					})
					.done(function(data) {
						// console.log("success");
						console.log(data)
						if (data.sing.is_check == 0) {
							// 正在审核中
							$(".maskBussiness").css({
								display: 'block'
							})
							setTimeout(function() {
								$(".mask").css({
									display: 'none'
								})
							}, 2000)
						}
						if (data.code == 500) {
							window.location.href = "bussinessEnter.html";

						}
						if (data.sing.is_check == 1) {
							// 审核通过
							$(".maskBussiness").html("您已成功入住我平台")
							$(".maskBussiness").css({
								display: 'block'
							})
							setTimeout(function() {
								$(".maskBussiness").css({
									display: 'none'
								})
							}, 2000)
						}
					})
					.fail(function() {
						console.log("error");
					})

			})
			// 二维码
		$(".QRcode").click(function(e) {
			e.preventDefault();
			$.ajax({
					url: 'http://www.teaweilai.com/app/Admin/AppRecommend/Er',
					type: 'POST',
					dataType: 'json',
					data: {
						uid: uid
					}
				})
				.done(function(data) {
					// console.log(data);
					$("#mask").css({
						display: 'block'
					});
					$("#show").css({
						display: 'block'
					})
					$(".showImg").attr("src", data.sing);

					$("body").click(function() {
						var event = event || window.event;
						var target = event.target || event.srcElement;
						// console.log(target);
						//如果点击的不是show才应该消失
						if (target.id !== "show") {
							$("#mask").css({
								display: 'none'
							});
							$("#show").css({
								display: 'none'
							});
						}
					})
				})
				.fail(function() {
					console.log("error");
				})
		})
	}


})